Skip to main content

sum

Type

function

Summary

Returns the sum of a list of numbers.

Syntax

sum(<numbersList>)

Description

Use the sum function to add a group of values together.

The sum function is equivalent to the following statements:

    repeat with x = 1 to the number of items of numbersList
add item x of numbersList to sumValue
end repeat
return sumValue

If the numbersList is empty, the sum function returns zero.

If a math operation on finite inputs produces a non-finite output, an execution error is thrown. See math operations for more information.

Parameters

NameTypeDescription

numbersList

numbers

  • a sequence of parameters, each a number or evaluating to a number or
  • a single parameter which is or evaluates to
    * a comma-separated list of numbers or
* an array containing only numbers

Examples

put sum(1,5,2,3) -- returns 11

glossary: statement, return, value, math operation

operator: plus

command: add, group

control structure: function

function: standardDeviation, min, max, extents

Compatibility and Support

Introduced

LiveCode 1.0

OS

mac

windows

linux

ios

android

Platforms

desktop

server

mobile

Thank you for your feedback!

Was this page helpful?